import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15

Item {
    id: root
    
    property int currentValue: 0
    property real scaleFactor: parent.width > 1000 ? 2.0 : 1.0
    
    // 数字图片路径数组
    readonly property var numberImages: [
        "qrc:/number/qrc/number/z0.png",
        "qrc:/number/qrc/number/z1.png",
        "qrc:/number/qrc/number/z2.png",
        "qrc:/number/qrc/number/z3.png",
        "qrc:/number/qrc/number/z4.png",
        "qrc:/number/qrc/number/z5.png",
        "qrc:/number/qrc/number/z6.png",
        "qrc:/number/qrc/number/z7.png",
        "qrc:/number/qrc/number/z8.png",
        "qrc:/number/qrc/number/z9.png"
    ]
    
    function increment() {
        currentValue++
        scaleAnimation.start()
    }
    
    Row {
        id: comboRow
        anchors.centerIn: parent
        spacing: 0
        
        // x图片 (44x100, y偏移-2)
        Image {
            width: 44 * scaleFactor
            height: 100 * scaleFactor
            source: "qrc:/number/qrc/number/zx.png"
            fillMode: Image.PreserveAspectFit
            y: -2 * scaleFactor
        }
        
        // 数字图片
        Repeater {
            model: root.currentValue.toString().split("")
            
            Image {
                width: (modelData === "1") ? 30 * scaleFactor : 50 * scaleFactor
                height: 100 * scaleFactor
                source: root.numberImages[parseInt(modelData)]
                fillMode: Image.PreserveAspectFit
            }
        }
    }
    
    // 缩放动画（从1.2倍缩放到1.0倍）
    SequentialAnimation {
        id: scaleAnimation
        
        PropertyAnimation {
            target: comboRow
            property: "scale"
            from: 1.2
            to: 1.0
            duration: 250
            easing.type: Easing.OutQuad
        }
    }
}
